<?php
	include_once('themes/head.php');	
	include_once('controller/daftarPembelianController.php');

?>
<pre>Daftar History Pembelian</pre>
<div id="daftar_beli">
<table class="table table-bordered">
	<thead>
		<th>
			Tanggal Pembelian
		</th>
		<th>
			Jumlah Produk
		</th>
		<th>
			Total Pembayaran
		</th>
		<th>
			&nbsp;
		</th>
	</thead>
	<?php
	if($daftar_pembelian==0)
	{
	?>
		<tr>
			<td colspan="4">Tidak Ada history Pembelian</td>
		</tr>
	<?php
	}
	else
	{
		foreach($daftar_pembelian as $daftar)
		{
	?>
	<tr>
		<td><?php echo $daftar['tgl_beli']; ?></td>
		<td><?php echo $daftar['jml_jns_bar']; ?></td>
		<td><?php echo $daftar['total_bayar']; ?></td>
		<td><a class="btn" href="daftar_pembelian.php?detail=<?php echo $daftar['id_beli']; ?>">Lihat Detail</a></td>
    <td><a class="btn" href="cetakstruk.php?detail=<?php echo $daftar['id_beli']; ?>">Cetak</a></td>
	</tr>
	<?php	
		}
	}
	?>
</table>
<table class="table table-striped">
	<?php
	if(isset($_GET['detail']))
	{
	?>
		<thead>
			<th colspan="4">Detail Pembelian</th>
		</thead>
	<?php
		foreach($daftar_detail as $detail)
		{
	?>
		<tr>
			<td><?php echo $detail['nama_produk']; ?></td>
			<td><?php echo $detail['nama']; ?></td>
			<td><?php echo $detail['harga']; ?></td>
			<td><?php echo $detail['jumlah']; ?></td>
			<td><center><a  class="btn" href="cetakdetilstruk.php?detail=<?php echo $daftar['id_beli']; ?>" >Cetak</a></td>
      		</tr>
						
			<?php
			
		}
	}
	?>
</table>

</div>
<?php
	include_once('themes/footer.php');
?>